package com.atguigu.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @Description: 具体的迭代器
 * @Author lixiaolong
 * @Date 2023/10/11
 */
public class InfoColleageIterator implements Iterator {


    List<Department> departmentList; // 集合方式存储
    int index = -1;//索引 下标


    public InfoColleageIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    //判断是否还有下一个元素
    @Override
    public boolean hasNext() {
        if (index >= departmentList.size() - 1) {
            return false;
        } else {
            index++;
            return true;
        }
    }

    @Override
    public Object next() {
        return departmentList.get(index);
    }

    public void remove() {

    }

}
